package com.hthy.futures.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.hthy.futures.R;
import com.hthy.futures.view.EmptyLayout;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.bingoogolapple.refreshlayout.BGANormalRefreshViewHolder;
import cn.bingoogolapple.refreshlayout.BGARefreshLayout;
import cn.bingoogolapple.refreshlayout.BGARefreshLayout.BGARefreshLayoutDelegate;


/**
 * T as the base bean
 * Created by Mr.bingley
 * on 16-5-23.
 */
public abstract class BaseListFragment extends BaseFragment implements BGARefreshLayoutDelegate {
    @Bind(R.id.bga)
    public BGARefreshLayout mRefreshLayout;
    @Bind(R.id.listView)
    public ListView listView;
    @Bind(R.id.error_layout)
    public EmptyLayout errorLayout;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_base_list2;
    }

    @Override
    protected void initWidget(View root) {
        super.initWidget(root);

        // 为BGARefreshLayout 设置代理  (必选）
        mRefreshLayout.setDelegate(this);
        mRefreshLayout.setRefreshViewHolder(new BGANormalRefreshViewHolder(getActivity(), true));
    }

    @Override
    public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout bgaRefreshLayout) {

    }

    @Override
    public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout bgaRefreshLayout) {
        return false;
    }

    /**
     * 结束刷新
     */
    protected void endResponse() {
        mRefreshLayout.endRefreshing();
        errorLayout.setErrorType(EmptyLayout.HIDE_LAYOUT);
    }

}
